<template>
  <c-panel :title="title">
    <el-row>
      <el-col :span=20>
        <el-button type="primary" icon="el-icon-search">导出</el-button>
      </el-col>
      <el-col :span=4>
        <el-input v-model="search" class="search" />
      </el-col>
    </el-row>
    <el-table :data="dataShow" stripe show-summary border fit style="width: 100%"
      :header-cell-style="{background:'#CCC',color:'#000'}">
      <el-table-column type="index" label="序号" width="50px" />
      <slot></slot>
    </el-table>
  </c-panel>
</template>

<script>
export default {
  name: "c-table",
  props: {
    title: {
      type: String,
      default: "title"
    },
    data: {
      type: Array
    }
  },
  data() {
    return {
      search: ""
    };
  },
  computed: {
    //快速筛选
    dataShow() {
      if (this.search) {
        return this.data.filter(dataRow => {
          let values = JSON.stringify(Object.values(dataRow));
          return values.indexOf(this.search) > -1;
        });
      }
      return this.data;
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.el-button--small {
  padding: 2px 16px 2px 16px;
}
.el-table thead {
  background: blue;
}

.search {
  padding: 6px 0px 0px 0px;
}
</style>
